package com.example.strategy.strategy;

import com.example.strategy.enums.RechargeTypeEnum;
import com.example.strategy.strategy.impl.BusiAcctStrategy;
import com.example.strategy.strategy.impl.CardStrategy;
import com.example.strategy.strategy.impl.EBankStrategy;
import com.example.strategy.strategy.impl.MobileStrategy;

import java.util.HashMap;
import java.util.Map;

public class StrategyFactory {

    private final static StrategyFactory factory=new StrategyFactory();
    private final static Map<Integer, Strategy> strategyMap=new HashMap();
    static {
        strategyMap.put(RechargeTypeEnum.E_BANK.value(),new EBankStrategy());
        strategyMap.put(RechargeTypeEnum.BUSI_ACCOUNTS.value(),new BusiAcctStrategy());
        strategyMap.put(RechargeTypeEnum.MOBILE.value(), new MobileStrategy());
        strategyMap.put(RechargeTypeEnum.CARD_RECHARGE.value(), new CardStrategy());
    }

    public StrategyFactory() {
    }

    public Strategy creator(Integer type){
        return strategyMap.get(type);
    }

    public static StrategyFactory getInstance(){
        return factory;
    }

}
